package com.readbook.service;

import com.readbook.dao.SjflDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SjflService {
    @Autowired
    private SjflDao sjflDao;

    public List<Map<String, Object>> Search_bookclass(Map<String, Object> gmap) {
        List<Map<String, Object>> list1 = sjflDao.Search_bookclass(gmap);
        return list1;
    }

    public List<Map<String, Object>> getPidClass() {
        List<Map<String, Object>> list1 = sjflDao.getPidClass();
        return list1;
    }


    public Map<String, Object> del_bookclass(Map<String, Object> gmap) {
        Map<String, Object> smap = new HashMap<>();
        //查询该分类是否已经有书籍
        List<Map<String, Object>> list1 = sjflDao.list_BookByClassid(gmap);
        if (list1.size() > 0) {
            smap.put("result", false);
            smap.put("msg", "该分类已经有了书籍,不能删除!");
        } else {
            sjflDao.del_bookclass(gmap);
            smap.put("result", true);
            smap.put("msg", "删除成功!");
        }
        return smap;
    }

    public int InsertBookclass(Map<String, Object> gmap) {
        return sjflDao.InsertBookclass(gmap);
    }

    public int EditBookclass(Map<String, Object> gmap) {
        return sjflDao.EditBookclass(gmap);
    }


}


